<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>抢单详情</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section class="itemgroup mt10">
    <div class="order_title" id="waybillNum"></div>

    <div class="addressitem ml15 font14 p10t">
        <span id="startAddr">
            <i class="iconfont mr5 green icon20">&#xe70d;</i>

        </span>
        <span class="mt5" id="startCross">
            <i class="iconfont mr5 gray icon20">&#xe723;</i>

        </span>
    </div>
    <div class="addressitem ml15 font14">
        <span id="endAddr">
            <i class="iconfont mr5 red icon20">&#xe70c;</i>

        </span>
        <span class="mt5" id="endCross">
            <i class="iconfont mr5 gray icon20">&#xe723;</i>

        </span>
    </div>
    
    <div>
        <div class="oneitem p15">
            <label class="gray font12">距离您:</label>
            <div class="comments_type right"> <font id="distanceWithU">0.05</font> 公里</div>
        </div>
    </div>

    <div id="requireList">
        <div class="oneitem p15">
            <label class="gray font12">特殊要求:</label>
            
        </div>
    </div>
</section>
<section class="itemgroup mt10 p15">
	<div class="oneitem">
      <label class="gray">给司机捎句话:</label>
  	<div class="pall15 font14 lh24" id="consignDesc"></div>
  </div>
</section>
<section class="itemgroup mt10 p15">
    <div class="oneitem">
        <label class="gray">联系人:</label>
        <i class="iconfont rightsmallicon">&#xe6db;</i>
        <label class="right" id="consignName"></label>
    </div>
</section>
<section class="itemgroup mt10 p15">
    <div class="oneitem">
        <div class="gray left">总计行驶:</div>
        <div class="right"><label class="mr5" id="planDistance"></label>公里</div>
    </div>
    <div class="oneitem">
        <div class="gray left">起步价(含<span id="exceedDistance"></span>公里内):</div>
        <div class="right"><label class="red mr5" id="planStartFee"></label>元</div>
    </div>
    <div class="oneitem">
        <div class="gray left">超里程运价(含<span id="exceedDistancePrice"></span>公里外):</div>
        <div class="right"><label class="red mr5" id="planExceedPrice"></label>元/公里</div>
    </div>
    <div class="oneitem">
        <div class="gray left">超里程费(含<span id="exceedDistance1"></span>公里外):</div>
        <div class="right"><label class="red mr5" id="planExceedFee"></label>元</div>
    </div>
    <div class="oneitem">
        <div class="gray left">预计等候时间:</div>
        <div class="right"><label class="mr5" id="planWaitTime"></label></div>
    </div>
    <div class="oneitem">
        <div class="gray left">特殊需求(搬运):</div>
        <div class="right"><label class="red mr5" id="planSpecialFee"></label>元</div>
    </div>
    <div class="oneitem" style="display:none;">
        <div class="gray left">装/卸货等待费用:</div>
        <div class="right"><label class="red mr5" id="planLoadFee"></label>元</div>
    </div>
    <div class="oneitem" style="display:none;">
        <div class="gray left">行驶途中等待费用:</div>
        <div class="right"><label class="red mr5" id="planLowSpeedFee"></label>元</div>
    </div>
</section>
<section class="sale_info">实际费用可能因实际行驶里程/等候时间等因素差异</section>
<section class="detialbottom">
    <button class="right btn addcert_det" id="goBid" onclick="goBid()">抢单</button>
    <div class="cart_clear2 ml15">
        <span class="font12">总费用:</span>
        <span class="red font16" id="planTotalFee">￥00</span>
    </div>
</section>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });
    $(document).ready(function () {
        var waybillId = GetArgsFromHref("waybillId");
        var url = _global.serverHost + "/driver/bid_detail.htm";
        var data = {waybillId: waybillId};
        _callAjaxRequest(url, data, goDetailBack);

        function goDetailBack(data) {
            var waybillSource = "订单:" + data.waybill.waybillNum;
            if (data.waybill.waybillSource == '10') {
                waybillSource = waybillSource + "<label class='type ml5'>APP</label>";
            } else if (data.waybill.waybillSource == '20') {
                waybillSource = waybillSource + "<label class='type ml5'>网站</label>";
            } else if (data.waybill.waybillSource == '30') {
                waybillSource = waybillSource + "<label class='type ml5'>客服电话</label>";
            } else if (data.waybill.waybillSource == '40') {
                waybillSource = waybillSource + "<label class='type ml5'>微信</label>";
            }
            waybillSource = waybillSource + '<label class="right gray">' + data.waybill.bookDate + '</label>';
            $("#waybillNum").html(waybillSource);
            $("#startAddr").html('<i class="iconfont mr5 green icon20">&#xe70d;</i>&nbsp;' + (data.waybill.startDistrict+data.waybill.startStreet));
            $("#startCross").html('<i class="iconfont mr5 gray icon20">&#xe723;</i>&nbsp;' + data.waybill.startCross);
            $("#endAddr").html('<i class="iconfont mr5 red icon20">&#xe70c;</i>&nbsp;' + (data.waybill.endDistrict+data.waybill.endStreet));
            $("#endCross").html('<i class="iconfont mr5 gray icon20">&#xe723;</i>&nbsp;' + data.waybill.endCross);

            var require = "";
            if (data.requireList.length > 0) {
                require = '<div class="oneitem p15">'
                        + '<label class="gray font12">特殊要求:</label>';
                for (var j = 0; j < data.requireList.length; j++) {
                    require = require + '<div class="comments_type right';
                    if (j > 0) {
                        require = require + ' mr5';
                    }
                    require = require + '">' + data.requireList[j].requirementName + '</div>';
                }
                require = require + '</div>';
            }
            $("#requireList").html(require);
            $("#consignDesc").html(data.waybill.consignDesc);
            $("#consignName").html(data.waybill.consignName);
            $("#planDistance").html(data.waybill.planDistance);
            $("#planStartFee").html(data.waybill.planStartFee);
            $("#planExceedFee").html(data.waybill.planExceedFee);
            $("#planSpecialFee").html(data.waybill.planSpecialFee);
            $("#planLowSpeedFee").html(data.waybill.planLowSpeedFee);
            $("#planLoadFee").html(data.waybill.planLoadFee*1+data.waybill.planUnloadFee*1);
            $("#planTotalFee").html("￥" + data.waybill.planTotalFee);
            $("#goBid").attr("onclick", "goBid(" + data.waybill.waybillId + ");");
            $("#exceedDistance").html(data.exceedDistance);
            $("#exceedDistance1").html(data.exceedDistance);
            $("#exceedDistancePrice").html(data.exceedDistance);
            $("#planExceedPrice").html(data.vehiclePrice.pv3);
            var ln_planWaitTime=data.waybill.planLoadTime-10+data.waybill.planUnloadTime+data.waybill.planLowSpeedTime;
            $("#planWaitTime").html(Number(ln_planWaitTime*60).formatTime());
            try{
							var distanceWith = delegate.getCurrentDistance(data.waybill.startLat,data.waybill.startLon);
							if(distanceWith){
								$("#distanceWithU").html(distanceWith);
							}
						}catch(e){
								//alert(e);
						}
        }
    });
    function goBid(waybillId) {
        var url = _global.serverHost + "/driver/go_bid.htm";
        var data = {waybillId: waybillId, driverUuid: getCookie("driverUuid")};
        _callAjaxRequest(url, data, goBidBack);
    }

    function goBidBack(data) {
        alert(data.message);
        if (data.code == "1") {
            window.location.href = "../bid/bid_ok_detail.html?waybillId=" + data.waybillId;
        }
    }
</script>
</body>
</html>